﻿namespace ApiTemplate.WebApi.Controllers
{
    /// <summary>
    /// 用户相关接口
    /// </summary>
    public class UserInfoController : BaseApiController
    {
        /// <summary>
        /// 用户相关服务
        /// </summary>
        public IUserInfoApplication UserInfoApplication { get; set; }

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="input">用户名</param>
        /// <returns>前端需要的用户信息</returns>
        [HttpPost]
        public async Task<UserLoginOutput> UserLoginAsync(UserLoginInput input)
        {
            return await UserInfoApplication.UserLoginAsync(input);
        }

        /// <summary>
        /// 演示用户授权
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [ServiceFilter(typeof(UserAuthorzationAttribute))]
        public bool DemoForUserAuthorzation()
        {
            return true;
        }

        /// <summary>
        /// 演示基本的授权
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [GlobalAuthorization]
        public bool DemoForGlobalAuthorization()
        {
            return true;
        }
    }
}
